#pragma once
#include <string>

enum
{
    DivError = 1,
    ModError,
    Unknown
};
class Task
{
public:
    Task(int x, int y, char op)
        : x_(x), y_(y), op_(op), result_(0), code_(0)
    {
    }
    ~Task()
    {
    }
    void operator()()
    {
        switch (op_)
        {
        case '+':
            result_ = x_ + y_;
            break;
        case '-':
            result_ = x_ - y_;
            break;
        case '*':
            result_ = x_ * y_;
            break;
        case '/':
            {
                if(y_ == 0) code_ = DivError;
                else result_ = x_ / y_;
            }
            break;
        case '%':
            {
                if(y_ == 0) code_ = ModError;
                else result_ = x_ % y_;
            }
            break;
        default:
            code_ = Unknown;
            break;
        }
    }

    std::string put_task()
    {
        return std::to_string(x_) + " " + op_ + std::to_string(y_) + " = ?";
    }

    std::string get_result()
    {
        return std::to_string(x_) + " " + op_ + std::to_string(y_) + " = " + std::to_string(result_) + " [code: " + std::to_string(code_) + "]";
    }
    

private:
    int x_;
    int y_;
    char op_;
    int result_;
    int code_;
};